define(['jquery', 'bootstrap', 'backend', 'table', 'form','wdsxh-colorpicker'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        add: function () {
            Controller.api.bindevent();

            //选择颜色
            var colorpickerObj=null;
            $(document).on("click", ".colorpicker", function () {
                that=this;
                var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
                var color=$("#" + input_id).val();
                if(!colorpickerObj){
                    colorpickerObj = Colorpicker.create({
                        el: "colorpicker",
                        color: color?color:'rgba(0,0,0)',
                        allMode: 'hex',
                        change: function (elem, rgba,hex) {
                            $("#" + input_id).val(hex);
                        }
                    });
                }

            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});